/*
 * FaceCat图形通讯框架
 * 著作权编号:2015SR229355+2020SR0266727
 * 上海卷卷猫信息技术有限公司
 */

using System;
using System.Collections.Generic;

namespace FaceCat
{
    /// <summary>
    /// 布尔型单元格
    /// </summary>
    public class FCGridBoolCell : FCGridCell
    {
        /// <summary>
        /// 创建布尔型单元格
        /// </summary>
        public FCGridBoolCell()
        {
        }

        /// <summary>
        /// 创建布尔型单元格
        /// </summary>
        /// <param name="value">数值</param>
        public FCGridBoolCell(bool value)
        {
            m_value = value;
        }

        /// <summary>
        /// 数值
        /// </summary>
        public bool m_value;

        /// <summary>
        /// 单元格大小比较，用于排序
        /// </summary>
        /// <param name="cell">比较单元格</param>
        /// <returns>1:较大 0:相等 -1:较小</returns>
        public override int compareTo(FCGridCell cell)
        {
            bool value = getBool();
            bool target = cell.getBool();
            if (value && !target)
            {
                return 1;
            }
            else if (!value && target)
            {
                return -1;
            }
            else
            {
                return 0;
            }
        }

        /// <summary>
        /// 获取布尔型数值
        /// </summary>
        /// <returns>布尔型数值</returns>
        public override bool getBool()
        {
            return m_value;
        }

        /// <summary>
        /// 获取双精度浮点值
        /// </summary>
        /// <returns>双精度浮点值</returns>
        public override double getDouble()
        {
            return m_value ? 1 : 0;
        }

        /// <summary>
        /// 获取单精度浮点值
        /// </summary>
        /// <returns>单精度浮点值</returns>
        public override float getFloat()
        {
            return m_value ? 1 : 0;
        }

        /// <summary>
        /// 获取整型数值
        /// </summary>
        /// <returns>整型数值</returns>
        public override int getInt()
        {
            return m_value ? 1 : 0;
        }

        /// <summary>
        /// 获取长整型数值
        /// </summary>
        /// <returns>长整型数值</returns>
        public override long getLong()
        {
            return m_value ? 1 : 0;
        }

        /// <summary>
        /// 获取字符型数值
        /// </summary>
        /// <returns>字符型数值</returns>
        public override String getString()
        {
            return m_value ? "true" : "false";
        }

        /// <summary>
        /// 设置布尔型数值
        /// </summary>
        /// <param name="value">数值</param>
        public override void setBool(bool value)
        {
            m_value = value;
        }

        /// <summary>
        /// 设置双精度浮点值
        /// </summary>
        /// <param name="value">数值</param>
        public override void setDouble(double value)
        {
            m_value = value > 0 ? true : false;
        }

        /// <summary>
        /// 设置单精度浮点值
        /// </summary>
        /// <param name="value">数值</param>
        public override void setFloat(float value)
        {
            m_value = value > 0 ? true : false;
        }

        /// <summary>
        /// 设置整型数值
        /// </summary>
        /// <param name="value">数值</param>
        public override void setInt(int value)
        {
            m_value = value > 0 ? true : false;
        }

        /// <summary>
        /// 设置长整型数值
        /// </summary>
        /// <param name="value">数值</param>
        public override void setLong(long value)
        {
            m_value = value > 0 ? true : false;
        }

        /// <summary>
        /// 设置字符型数值
        /// </summary>
        /// <param name="value">数值</param>
        public override void setString(String value)
        {
            m_value = value == "true" ? true : false;
        }
    }

    /// <summary>
    /// 按钮视图单元格
    /// </summary>
    public class FCGridButtonCell : FCGridViewCell
    {
        /// <summary>
        /// 创建按钮视图单元格
        /// </summary>
        public FCGridButtonCell()
        {
            FCButton button = new FCButton();
            button.setBorderColor(FCColor.None);
            button.setDisplayOffset(false);
            setView(button);
        }

        /// <summary>
        /// 获取按钮
        /// </summary>
        public FCButton getButton()
        {
            if (getView() != null)
            {
                return getView() as FCButton;
            }
            else
            {
                return null;
            }
        }
    }

    /// <summary>
    /// 复选框视图单元格
    /// </summary>
    public class FCGridCheckBoxCell : FCGridViewCell
    {
        /// <summary>
        /// 创建复选框视图单元格
        /// </summary>
        public FCGridCheckBoxCell()
        {
            FCCheckBox checkBox = new FCCheckBox();
            checkBox.setDisplayOffset(false);
            checkBox.setButtonAlign(FCHorizontalAlign.Center);
            setView(checkBox);
        }

        /// <summary>
        /// 获取复选框视图
        /// </summary>
        public FCCheckBox getCheckBox()
        {
            if (getView() != null)
            {
                return getView() as FCCheckBox;
            }
            else
            {
                return null;
            }
        }

        /// <summary>
        /// 获取布尔型数值
        /// </summary>
        /// <returns>布尔型数值</returns>
        public override bool getBool()
        {
            FCCheckBox checkBox = getCheckBox();
            if (checkBox != null)
            {
                return checkBox.isChecked();
            }
            else
            {
                return false;
            }
        }

        /// <summary>
        /// 获取双精度浮点值
        /// </summary>
        /// <returns>双精度浮点值</returns>
        public override double getDouble()
        {
            FCCheckBox checkBox = getCheckBox();
            if (checkBox != null)
            {
                return checkBox.isChecked() ? 1 : 0;
            }
            else
            {
                return 0;
            }
        }

        /// <summary>
        /// 获取单精度浮点值
        /// </summary>
        /// <returns>单精度浮点值</returns>
        public override float getFloat()
        {
            FCCheckBox checkBox = getCheckBox();
            if (checkBox != null)
            {
                return checkBox.isChecked() ? 1 : 0;
            }
            else
            {
                return 0;
            }
        }

        /// <summary>
        /// 获取整型数值
        /// </summary>
        /// <returns>整型数值</returns>
        public override int getInt()
        {
            FCCheckBox checkBox = getCheckBox();
            if (checkBox != null)
            {
                return checkBox.isChecked() ? 1 : 0;
            }
            else
            {
                return 0;
            }
        }

        /// <summary>
        /// 获取长整型数值
        /// </summary>
        /// <returns>长整型数值</returns>
        public override long getLong()
        {
            FCCheckBox checkBox = getCheckBox();
            if (checkBox != null)
            {
                return checkBox.isChecked() ? 1 : 0;
            }
            else
            {
                return 0;
            }
        }

        /// <summary>
        /// 获取布尔型数值
        /// </summary>
        /// <returns></returns>
        public override String getString()
        {
            FCCheckBox checkBox = getCheckBox();
            if (checkBox != null)
            {
                return checkBox.isChecked() ? "true" : "false";
            }
            else
            {
                return "false";
            }
        }

        /// <summary>
        /// 设置布尔型数值
        /// </summary>
        /// <param name="value">数值</param>
        public override void setBool(bool value)
        {
            FCCheckBox checkBox = getCheckBox();
            if (checkBox != null)
            {
                checkBox.setChecked(value);
            }
        }

        /// <summary>
        /// 设置双精度浮点值
        /// </summary>
        /// <param name="value">数值</param>
        public override void setDouble(double value)
        {
            FCCheckBox checkBox = getCheckBox();
            if (checkBox != null)
            {
                checkBox.setChecked(value > 0 ? true : false);
            }
        }

        /// <summary>
        /// 设置单精度浮点值
        /// </summary>
        /// <param name="value">数值</param>
        public override void setFloat(float value)
        {
            FCCheckBox checkBox = getCheckBox();
            if (checkBox != null)
            {
                checkBox.setChecked(value > 0 ? true : false);
            }
        }

        /// <summary>
        /// 设置整型数值
        /// </summary>
        /// <param name="value">数值</param>
        public override void setInt(int value)
        {
            FCCheckBox checkBox = getCheckBox();
            if (checkBox != null)
            {
                checkBox.setChecked(value > 0 ? true : false);
            }
        }

        /// <summary>
        /// 设置长整型数值
        /// </summary>
        /// <param name="value">数值</param>
        public override void setLong(long value)
        {
            FCCheckBox checkBox = getCheckBox();
            if (checkBox != null)
            {
                checkBox.setChecked(value > 0 ? true : false);
            }
        }

        /// <summary>
        /// 设置字符型数值
        /// </summary>
        /// <param name="value"></param>
        public override void setString(String value)
        {
            FCCheckBox checkBox = getCheckBox();
            if (checkBox != null)
            {
                checkBox.setChecked(value == "true");
            }
        }
    }

    /// <summary>
    /// 下拉菜单型单元格
    /// </summary>
    public class FCGridComboBoxCell : FCGridViewCell
    {
        /// <summary>
        /// 下拉菜单型单元格
        /// </summary>
        public FCGridComboBoxCell()
        {
            FCComboBox comboBox = new FCComboBox();
            comboBox.setBorderColor(FCColor.None);
            comboBox.setDisplayOffset(false);
            setView(comboBox);
        }

        /// <summary>
        /// 获取按钮视图
        /// </summary>
        public FCComboBox getComboBox()
        {
            if (getView() != null)
            {
                return getView() as FCComboBox;
            }
            else
            {
                return null;
            }
        }

        /// <summary>
        /// 获取布尔型数值
        /// </summary>
        /// <returns>布尔型数值</returns>
        public override bool getBool()
        {
            FCComboBox comboBox = getComboBox();
            if (comboBox != null)
            {
                return comboBox.getSelectedIndex() > 0;
            }
            else
            {
                return false;
            }
        }

        /// <summary>
        /// 获取双精度浮点值
        /// </summary>
        /// <returns>双精度浮点值</returns>
        public override double getDouble()
        {
            FCComboBox comboBox = getComboBox();
            if (comboBox != null)
            {
                return (double)comboBox.getSelectedIndex();
            }
            else
            {
                return 0;
            }
        }

        /// <summary>
        /// 获取单精度浮点值
        /// </summary>
        /// <returns>单精度浮点值</returns>
        public override float getFloat()
        {
            FCComboBox comboBox = getComboBox();
            if (comboBox != null)
            {
                return (float)comboBox.getSelectedIndex();
            }
            else
            {
                return 0;
            }
        }

        /// <summary>
        /// 获取整型数值
        /// </summary>
        /// <returns>整型数值</returns>
        public override int getInt()
        {
            FCComboBox comboBox = getComboBox();
            if (comboBox != null)
            {
                return comboBox.getSelectedIndex();
            }
            else
            {
                return 0;
            }
        }

        /// <summary>
        /// 获取长整型数值
        /// </summary>
        /// <returns>长整型数值</returns>
        public override long getLong()
        {
            FCComboBox comboBox = getComboBox();
            if (comboBox != null)
            {
                return (long)comboBox.getSelectedIndex();
            }
            else
            {
                return 0;
            }
        }

        /// <summary>
        /// 获取布尔型数值
        /// </summary>
        /// <returns>字符串</returns>
        public override String getString()
        {
            FCComboBox comboBox = getComboBox();
            if (comboBox != null)
            {
                return comboBox.getSelectedValue();
            }
            else
            {
                return "";
            }
        }

        /// <summary>
        /// 设置布尔型数值
        /// </summary>
        /// <param name="value">数值</param>
        public override void setBool(bool value)
        {
            FCComboBox comboBox = getComboBox();
            if (comboBox != null)
            {
                comboBox.setSelectedIndex(value ? 1 : 0);
            }
        }

        /// <summary>
        /// 设置双精度浮点值
        /// </summary>
        /// <param name="value">数值</param>
        public override void setDouble(double value)
        {
            FCComboBox comboBox = getComboBox();
            if (comboBox != null)
            {
                comboBox.setSelectedIndex((int)value);
            }
        }

        /// <summary>
        /// 设置单精度浮点值
        /// </summary>
        /// <param name="value">数值</param>
        public override void setFloat(float value)
        {
            FCComboBox comboBox = getComboBox();
            if (comboBox != null)
            {
                comboBox.setSelectedIndex((int)value);
            }
        }

        /// <summary>
        /// 设置整型数值
        /// </summary>
        /// <param name="value">数值</param>
        public override void setInt(int value)
        {
            FCComboBox comboBox = getComboBox();
            if (comboBox != null)
            {
                comboBox.setSelectedIndex(value);
            }
        }

        /// <summary>
        /// 设置长整型数值
        /// </summary>
        /// <param name="value">数值</param>
        public override void setLong(long value)
        {
            FCComboBox comboBox = getComboBox();
            if (comboBox != null)
            {
                comboBox.setSelectedIndex((int)value);
            }
        }

        /// <summary>
        /// 设置字符型数值
        /// </summary>
        /// <param name="value">数值</param>
        public override void setString(String value)
        {
            FCComboBox comboBox = getComboBox();
            if (comboBox != null)
            {
                comboBox.setSelectedValue(value);
            }
        }
    }

    /// <summary>
    /// 日期视图单元格
    /// </summary>
    public class FCGridDateTimePickerCell : FCGridViewCell
    {
        /// <summary>
        /// 创建日期视图单元格
        /// </summary>
        public FCGridDateTimePickerCell()
        {
            FCDateTimePicker datePicker = new FCDateTimePicker();
            datePicker.setBorderColor(FCColor.None);
            datePicker.setDisplayOffset(false);
            setView(datePicker);
        }

        /// <summary>
        /// 获取按钮视图
        /// </summary>
        public FCDateTimePicker getDatePicker()
        {
            if (getView() != null)
            {
                return getView() as FCDateTimePicker;
            }
            else
            {
                return null;
            }
        }
    }

    /// <summary>
    /// 层视图单元格
    /// </summary>
    public class FCGridDivCell : FCGridViewCell
    {
        /// <summary>
        /// 创建层视图单元格
        /// </summary>
        public FCGridDivCell()
        {
            FCDiv div = new FCDiv();
            div.setBorderColor(FCColor.None);
            div.setDisplayOffset(false);
            setView(div);
        }

        /// <summary>
        /// 获取层视图
        /// </summary>
        public FCDiv getDiv()
        {
            if (getView() != null)
            {
                return getView() as FCDiv;
            }
            else
            {
                return null;
            }
        }
    }

    /// <summary>
    /// 双精度浮点型单元格
    /// </summary>
    public class FCGridDoubleCell : FCGridCell
    {
        /// <summary>
        /// 创建双精度浮点型单元格
        /// </summary>
        public FCGridDoubleCell()
        {
        }

        /// <summary>
        /// 创建双精度浮点型单元格
        /// </summary>
        /// <param name="value">数值</param>
        public FCGridDoubleCell(double value)
        {
            m_value = value;
        }

        /// <summary>
        /// 数值
        /// </summary>
        public double m_value;

        public int m_digit = -1;

        /// <summary>
        /// 获取保留小数的位数
        /// </summary>
        public int getDigit()
        {
            return m_digit;
        }

        /// <summary>
        /// 设置保留小数的位数
        /// </summary>
        public void setDigit(int value)
        {
            m_digit = value;
        }

        /// <summary>
        /// 单元格大小比较，用于排序
        /// </summary>
        /// <param name="cell">比较单元格</param>
        /// <returns>1:较大 0:相等 -1:较小</returns>
        public override int compareTo(FCGridCell cell)
        {
            double value = getDouble();
            double target = cell.getDouble();
            if (value > target)
            {
                return 1;
            }
            else if (value < target)
            {
                return -1;
            }
            else
            {
                return 0;
            }
        }

        /// <summary>
        /// 获取布尔型数值
        /// </summary>
        /// <returns>布尔型数值</returns>
        public override bool getBool()
        {
            return m_value == 0 ? false : true;
        }

        /// <summary>
        /// 获取双精度浮点值
        /// </summary>
        /// <returns>双精度浮点值</returns>
        public override double getDouble()
        {
            return m_value;
        }

        /// <summary>
        /// 获取单精度浮点值
        /// </summary>
        /// <returns>单精度浮点值</returns>
        public override float getFloat()
        {
            return (float)m_value;
        }

        /// <summary>
        /// 获取整型数值
        /// </summary>
        /// <returns>整型数值</returns>
        public override int getInt()
        {
            return (int)m_value;
        }

        /// <summary>
        /// 获取长整型数值
        /// </summary>
        /// <returns>长整型数值</returns>
        public override long getLong()
        {
            return (long)m_value;
        }

        /// <summary>
        /// 获取字符型数值
        /// </summary>
        /// <returns>字符型数值</returns>
        public override String getString()
        {
            return m_value.ToString();
        }

        /// <summary>
        /// 设置布尔型数值
        /// </summary>
        /// <param name="value">数值</param>
        public override void setBool(bool value)
        {
            m_value = value ? 1 : 0;
        }

        /// <summary>
        /// 设置双精度浮点值
        /// </summary>
        /// <param name="value">数值</param>
        public override void setDouble(double value)
        {
            m_value = value;
        }

        /// <summary>
        /// 设置单精度浮点值
        /// </summary>
        /// <param name="value">数值</param>
        public override void setFloat(float value)
        {
            m_value = value;
        }

        /// <summary>
        /// 设置整型数值
        /// </summary>
        /// <param name="value">数值</param>
        public override void setInt(int value)
        {
            m_value = value;
        }

        /// <summary>
        /// 设置长整型数值
        /// </summary>
        /// <param name="value">数值</param>
        public override void setLong(long value)
        {
            m_value = (double)value;
        }

        /// <summary>
        /// 设置字符型数值
        /// </summary>
        /// <param name="value">数值</param>
        public override void setString(String value)
        {
            m_value = FCTran.strToDouble(value);
        }

        /// <summary>
        /// 获取要绘制的文字
        /// </summary>
        /// <returns></returns>
        public override String getPaintText()
        {
            if (getDigit() == -1)
            {
                return FCTran.doubleToStr(getDouble());
            }
            else
            {
                return FCTran.getValueByDigit(getDouble(), getDigit());
            }
        }
    }

    /// <summary>
    /// 单精度浮点型单元格
    /// </summary>
    public class FCGridFloatCell : FCGridCell
    {
        /// <summary>
        /// 创建单精度浮点型单元格
        /// </summary>
        public FCGridFloatCell()
        {
        }

        /// <summary>
        /// 创建单精度浮点型单元格
        /// </summary>
        /// <param name="value">数值</param>
        public FCGridFloatCell(float value)
        {
            m_value = value;
        }

        /// <summary>
        /// 数值
        /// </summary>
        public float m_value;

        /// <summary>
        /// 单元格大小比较，用于排序
        /// </summary>
        /// <param name="cell">比较单元格</param>
        /// <returns>1:较大 0:相等 -1:较小</returns>
        public override int compareTo(FCGridCell cell)
        {
            float value = getFloat();
            float target = cell.getFloat();
            if (value > target)
            {
                return 1;
            }
            else if (value < target)
            {
                return -1;
            }
            else
            {
                return 0;
            }
        }

        /// <summary>
        /// 获取布尔型数值
        /// </summary>
        /// <returns>布尔型数值</returns>
        public override bool getBool()
        {
            return m_value == 0 ? false : true;
        }

        /// <summary>
        /// 获取双精度浮点值
        /// </summary>
        /// <returns>双精度浮点值</returns>
        public override double getDouble()
        {
            return m_value;
        }

        /// <summary>
        /// 获取单精度浮点值
        /// </summary>
        /// <returns>单精度浮点值</returns>
        public override float getFloat()
        {
            return m_value;
        }

        /// <summary>
        /// 获取整型数值
        /// </summary>
        /// <returns>整型数值</returns>
        public override int getInt()
        {
            return (int)m_value;
        }

        /// <summary>
        /// 获取长整型数值
        /// </summary>
        /// <returns>长整型数值</returns>
        public override long getLong()
        {
            return (long)m_value;
        }

        /// <summary>
        /// 获取字符型数值
        /// </summary>
        /// <returns>字符型数值</returns>
        public override String getString()
        {
            return m_value.ToString();
        }

        /// <summary>
        /// 设置布尔型数值
        /// </summary>
        /// <param name="value">数值</param>
        public override void setBool(bool value)
        {
            m_value = value ? 1 : 0;
        }

        /// <summary>
        /// 设置双精度浮点值
        /// </summary>
        /// <param name="value">数值</param>
        public override void setDouble(double value)
        {
            m_value = (float)value;
        }

        /// <summary>
        /// 设置单精度浮点值
        /// </summary>
        /// <param name="value">数值</param>
        public override void setFloat(float value)
        {
            m_value = value;
        }

        /// <summary>
        /// 设置整型数值
        /// </summary>
        /// <param name="value">数值</param>
        public override void setInt(int value)
        {
            m_value = value;
        }

        /// <summary>
        /// 设置长整型数值
        /// </summary>
        /// <param name="value">数值</param>
        public override void setLong(long value)
        {
            m_value = (float)value;
        }

        /// <summary>
        /// 设置字符型数值
        /// </summary>
        /// <param name="value">数值</param>
        public override void setString(String value)
        {
            m_value = (float)FCTran.strToDouble(value);
        }
    }

    /// <summary>
    /// 整型单元格
    /// </summary>
    public class FCGridIntCell : FCGridCell
    {
        /// <summary>
        /// 创建整型单元格
        /// </summary>
        public FCGridIntCell()
        {
        }

        /// <summary>
        /// 创建整型单元格
        /// </summary>
        /// <param name="value">数值</param>
        public FCGridIntCell(int value)
        {
            m_value = value;
        }

        /// <summary>
        /// 数值
        /// </summary>
        public int m_value;

        /// <summary>
        /// 单元格大小比较，用于排序
        /// </summary>
        /// <param name="cell">比较单元格</param>
        /// <returns>1:较大 0:相等 -1:较小</returns>
        public override int compareTo(FCGridCell cell)
        {
            int value = getInt();
            int target = cell.getInt();
            if (value > target)
            {
                return 1;
            }
            else if (value < target)
            {
                return -1;
            }
            else
            {
                return 0;
            }
        }

        /// <summary>
        /// 获取布尔型数值
        /// </summary>
        /// <returns>布尔型数值</returns>
        public override bool getBool()
        {
            return m_value == 0 ? false : true;
        }

        /// <summary>
        /// 获取双精度浮点值
        /// </summary>
        /// <returns>双精度浮点值</returns>
        public override double getDouble()
        {
            return m_value;
        }

        /// <summary>
        /// 获取单精度浮点值
        /// </summary>
        /// <returns>单精度浮点值</returns>
        public override float getFloat()
        {
            return m_value;
        }

        /// <summary>
        /// 获取整型数值
        /// </summary>
        /// <returns>整型数值</returns>
        public override int getInt()
        {
            return m_value;
        }

        /// <summary>
        /// 获取长整型数值
        /// </summary>
        /// <returns>长整型数值</returns>
        public override long getLong()
        {
            return m_value;
        }

        /// <summary>
        /// 获取字符型数值
        /// </summary>
        /// <returns>字符型数值</returns>
        public override String getString()
        {
            return m_value.ToString();
        }

        /// <summary>
        /// 设置布尔型数值
        /// </summary>
        /// <param name="value">数值</param>
        public override void setBool(bool value)
        {
            m_value = value ? 1 : 0;
        }

        /// <summary>
        /// 设置双精度浮点值
        /// </summary>
        /// <param name="value">数值</param>
        public override void setDouble(double value)
        {
            m_value = (int)value;
        }

        /// <summary>
        /// 设置单精度浮点值
        /// </summary>
        /// <param name="value">数值</param>
        public override void setFloat(float value)
        {
            m_value = (int)value;
        }

        /// <summary>
        /// 设置整型数值
        /// </summary>
        /// <param name="value">数值</param>
        public override void setInt(int value)
        {
            m_value = value;
        }

        /// <summary>
        /// 设置长整型数值
        /// </summary>
        /// <param name="value">数值</param>
        public override void setLong(long value)
        {
            m_value = (int)value;
        }

        /// <summary>
        /// 设置字符型数值
        /// </summary>
        /// <param name="value">数值</param>
        public override void setString(String value)
        {
            m_value = FCTran.strToInt(value);
        }
    }

    /// <summary>
    /// 标签型单元格
    /// </summary>
    public class FCGridLabelCell : FCGridViewCell
    {
        /// <summary>
        /// 创建标签单元格
        /// </summary>
        public FCGridLabelCell()
        {
            FCLabel label = new FCLabel();
            label.setBorderColor(FCColor.None);
            label.setDisplayOffset(false);
            setView(label);
        }

        /// <summary>
        /// 获取标签视图
        /// </summary>
        public FCLabel getLabel()
        {
            if (getView() != null)
            {
                return getView() as FCLabel;
            }
            else
            {
                return null;
            }
        }
    }

    /// <summary>
    /// 长整型单元格
    /// </summary>
    public class FCGridLongCell : FCGridCell
    {
        /// <summary>
        /// 创建长整型单元格
        /// </summary>
        public FCGridLongCell()
        {
        }

        /// <summary>
        /// 创建长整型单元格
        /// </summary>
        /// <param name="value">数值</param>
        public FCGridLongCell(long value)
        {
            m_value = value;
        }

        /// <summary>
        /// 数值
        /// </summary>
        public long m_value;

        /// <summary>
        /// 单元格大小比较，用于排序
        /// </summary>
        /// <param name="cell">比较单元格</param>
        /// <returns>1:较大 0:相等 -1:较小</returns>
        public override int compareTo(FCGridCell cell)
        {
            long value = getLong();
            long target = cell.getLong();
            if (value > target)
            {
                return 1;
            }
            else if (value < target)
            {
                return -1;
            }
            else
            {
                return 0;
            }
        }

        /// <summary>
        /// 获取布尔型数值
        /// </summary>
        /// <returns>布尔型数值</returns>
        public override bool getBool()
        {
            return m_value == 0 ? false : true;
        }

        /// <summary>
        /// 获取双精度浮点值
        /// </summary>
        /// <returns>双精度浮点值</returns>
        public override double getDouble()
        {
            return m_value;
        }

        /// <summary>
        /// 获取单精度浮点值
        /// </summary>
        /// <returns>单精度浮点值</returns>
        public override float getFloat()
        {
            return m_value;
        }

        /// <summary>
        /// 获取整型数值
        /// </summary>
        /// <returns>整型数值</returns>
        public override int getInt()
        {
            return (int)m_value;
        }

        /// <summary>
        /// 获取长整型数值
        /// </summary>
        /// <returns>长整型数值</returns>
        public override long getLong()
        {
            return m_value;
        }

        /// <summary>
        /// 获取字符型数值
        /// </summary>
        /// <returns>字符型数值</returns>
        public override String getString()
        {
            return m_value.ToString();
        }


        /// <summary>
        /// 设置布尔型数值
        /// </summary>
        /// <param name="value">数值</param>
        public override void setBool(bool value)
        {
            m_value = value ? 1 : 0;
        }

        /// <summary>
        /// 设置双精度浮点值
        /// </summary>
        /// <param name="value">数值</param>
        public override void setDouble(double value)
        {
            m_value = (long)value;
        }

        /// <summary>
        /// 设置单精度浮点值
        /// </summary>
        /// <param name="value">数值</param>
        public override void setFloat(float value)
        {
            m_value = (long)value;
        }

        /// <summary>
        /// 设置整型数值
        /// </summary>
        /// <param name="value">数值</param>
        public override void setInt(int value)
        {
            m_value = value;
        }

        /// <summary>
        /// 设置长整型数值
        /// </summary>
        /// <param name="value">数值</param>
        public override void setLong(long value)
        {
            m_value = value;
        }

        /// <summary>
        /// 设置字符型数值
        /// </summary>
        /// <param name="value">数值</param>
        public override void setString(String value)
        {
            m_value = (long)FCTran.strToInt(value);
        }
    }

    /// <summary>
    /// 密码型单元格
    /// </summary>
    public class FCGridPasswordCell : FCGridStringCell
    {
        /// <summary>
        /// 获取要绘制的文本
        /// </summary>
        /// <returns>文本</returns>
        public override String getPaintText()
        {
            return "******";
        }
    }

    /// <summary>
    /// 单选按钮单元格
    /// </summary>
    public class GridRadioButtonCell : FCGridViewCell
    {
        /// <summary>
        /// 创建单选按钮单元格
        /// </summary>
        public GridRadioButtonCell()
        {
            FCRadioButton radioButton = new FCRadioButton();
            radioButton.setBorderColor(FCColor.None);
            radioButton.setDisplayOffset(false);
            setView(radioButton);
        }

        /// <summary>
        /// 获取按钮视图
        /// </summary>
        public FCRadioButton getRadioButton()
        {
            if (getView() != null)
            {
                return getView() as FCRadioButton;
            }
            else
            {
                return null;
            }
        }

        /// <summary>
        /// 获取布尔型数值
        /// </summary>
        /// <returns>布尔型数值</returns>
        public override bool getBool()
        {
            FCRadioButton radioButton = getRadioButton();
            if (radioButton != null)
            {
                return radioButton.isChecked();
            }
            else
            {
                return false;
            }
        }

        /// <summary>
        /// 获取双精度浮点值
        /// </summary>
        /// <returns>双精度浮点值</returns>
        public override double getDouble()
        {
            FCRadioButton radioButton = getRadioButton();
            if (radioButton != null)
            {
                return radioButton.isChecked() ? 1 : 0;
            }
            else
            {
                return 0;
            }
        }

        /// <summary>
        /// 获取单精度浮点值
        /// </summary>
        /// <returns>单精度浮点值</returns>
        public override float getFloat()
        {
            FCRadioButton radioButton = getRadioButton();
            if (radioButton != null)
            {
                return radioButton.isChecked() ? 1 : 0;
            }
            else
            {
                return 0;
            }
        }

        /// <summary>
        /// 获取整型数值
        /// </summary>
        /// <returns>整型数值</returns>
        public override int getInt()
        {
            FCRadioButton radioButton = getRadioButton();
            if (radioButton != null)
            {
                return radioButton.isChecked() ? 1 : 0;
            }
            else
            {
                return 0;
            }
        }

        /// <summary>
        /// 获取长整型数值
        /// </summary>
        /// <returns>长整型数值</returns>
        public override long getLong()
        {
            FCRadioButton radioButton = getRadioButton();
            if (radioButton != null)
            {
                return radioButton.isChecked() ? 1 : 0;
            }
            else
            {
                return 0;
            }
        }

        /// <summary>
        /// 获取布尔型数值
        /// </summary>
        /// <returns></returns>
        public override String getString()
        {
            FCRadioButton radioButton = getRadioButton();
            if (radioButton != null)
            {
                return radioButton.isChecked() ? "true" : "false";
            }
            else
            {
                return "false";
            }
        }

        /// <summary>
        /// 设置布尔型数值
        /// </summary>
        /// <param name="value">数值</param>
        public override void setBool(bool value)
        {
            FCRadioButton radioButton = getRadioButton();
            if (radioButton != null)
            {
                radioButton.setChecked(value);
            }
        }

        /// <summary>
        /// 设置双精度浮点值
        /// </summary>
        /// <param name="value">数值</param>
        public override void setDouble(double value)
        {
            FCRadioButton radioButton = getRadioButton();
            if (radioButton != null)
            {
                radioButton.setChecked(value > 0 ? true : false);
            }
        }

        /// <summary>
        /// 设置单精度浮点值
        /// </summary>
        /// <param name="value">数值</param>
        public override void setFloat(float value)
        {
            FCRadioButton radioButton = getRadioButton();
            if (radioButton != null)
            {
                radioButton.setChecked(value > 0 ? true : false);
            }
        }

        /// <summary>
        /// 设置整型数值
        /// </summary>
        /// <param name="value">数值</param>
        public override void setInt(int value)
        {
            FCRadioButton radioButton = getRadioButton();
            if (radioButton != null)
            {
                radioButton.setChecked(value > 0 ? true : false);
            }
        }

        /// <summary>
        /// 设置长整型数值
        /// </summary>
        /// <param name="value">数值</param>
        public override void setLong(long value)
        {
            FCRadioButton radioButton = getRadioButton();
            if (radioButton != null)
            {
                radioButton.setChecked(value > 0 ? true : false);
            }
        }

        /// <summary>
        /// 设置字符型数值
        /// </summary>
        /// <param name="value"></param>
        public override void setString(String value)
        {
            FCRadioButton radioButton = getRadioButton();
            if (radioButton != null)
            {
                radioButton.setChecked(value == "true");
            }
        }
    }

    /// <summary>
    /// 数值框单元格
    /// </summary>
    public class FCGridSpinCell : FCGridViewCell
    {
        /// <summary>
        /// 创建输入框单元格
        /// </summary>
        public FCGridSpinCell()
        {
            FCSpin spin = new FCSpin();
            spin.setBorderColor(FCColor.None);
            spin.setDisplayOffset(false);
            setView(spin);
        }

        /// <summary>
        /// 获取输入框视图
        /// </summary>
        public FCSpin getSpin()
        {
            if (getView() != null)
            {
                return getView() as FCSpin;
            }
            else
            {
                return null;
            }
        }

        /// <summary>
        /// 获取布尔型数值
        /// </summary>
        /// <returns>布尔型数值</returns>
        public override bool getBool()
        {
            FCSpin spin = getSpin();
            if (spin != null)
            {
                return spin.getValue() > 0;
            }
            else
            {
                return false;
            }
        }

        /// <summary>
        /// 获取双精度浮点值
        /// </summary>
        /// <returns>双精度浮点值</returns>
        public override double getDouble()
        {
            FCSpin spin = getSpin();
            if (spin != null)
            {
                return spin.getValue();
            }
            else
            {
                return 0;
            }
        }

        /// <summary>
        /// 获取单精度浮点值
        /// </summary>
        /// <returns>单精度浮点值</returns>
        public override float getFloat()
        {
            FCSpin spin = getSpin();
            if (spin != null)
            {
                return (float)spin.getValue();
            }
            else
            {
                return 0;
            }
        }

        /// <summary>
        /// 获取整型数值
        /// </summary>
        /// <returns>整型数值</returns>
        public override int getInt()
        {
            FCSpin spin = getSpin();
            if (spin != null)
            {
                return (int)spin.getValue();
            }
            else
            {
                return 0;
            }
        }

        /// <summary>
        /// 获取长整型数值
        /// </summary>
        /// <returns>长整型数值</returns>
        public override long getLong()
        {
            FCSpin spin = getSpin();
            if (spin != null)
            {
                return (long)spin.getValue();
            }
            else
            {
                return 0;
            }
        }

        /// <summary>
        /// 设置布尔型数值
        /// </summary>
        /// <param name="value">数值</param>
        public override void setBool(bool value)
        {
            FCSpin spin = getSpin();
            if (spin != null)
            {
                spin.setValue(value ? 1 : 0);
            }
        }

        /// <summary>
        /// 设置双精度浮点值
        /// </summary>
        /// <param name="value">数值</param>
        public override void setDouble(double value)
        {
            FCSpin spin = getSpin();
            if (spin != null)
            {
                spin.setValue(value);
            }
        }

        /// <summary>
        /// 设置单精度浮点值
        /// </summary>
        /// <param name="value">数值</param>
        public override void setFloat(float value)
        {
            FCSpin spin = getSpin();
            if (spin != null)
            {
                spin.setValue((double)value);
            }
        }

        /// <summary>
        /// 设置整型数值
        /// </summary>
        /// <param name="value">数值</param>
        public override void setInt(int value)
        {
            FCSpin spin = getSpin();
            if (spin != null)
            {
                spin.setValue((double)value);
            }
        }

        /// <summary>
        /// 设置长整型数值
        /// </summary>
        /// <param name="value">数值</param>
        public override void setLong(long value)
        {
            FCSpin spin = getSpin();
            if (spin != null)
            {
                spin.setValue((double)value);
            }
        }
    }

    /// <summary>
    /// 字符型单元格
    /// </summary>
    public class FCGridStringCell : FCGridCell
    {
        /// <summary>
        /// 创建字符型单元格
        /// </summary>
        public FCGridStringCell()
        {
        }

        /// <summary>
        /// 创建字符型单元格
        /// </summary>
        /// <param name="value">数值</param>
        public FCGridStringCell(String value)
        {
            m_value = value;
        }

        /// <summary>
        /// 字符
        /// </summary>
        public String m_value;

        /// <summary>
        /// 单元格大小比较，用于排序
        /// </summary>
        /// <param name="cell">比较单元格</param>
        /// <returns>1:较大 0:相等 -1:较小</returns>
        public override int compareTo(FCGridCell cell)
        {
            String target = cell.getString();
            String value = getString();
            if (value != null)
            {
                return value.CompareTo(target);
            }
            return -1;
        }

        /// <summary>
        /// 获取字符型数值
        /// </summary>
        /// <returns>字符型数值</returns>
        public override String getString()
        {
            return m_value;
        }

        /// <summary>
        /// 设置字符型数值
        /// </summary>
        /// <param name="value">数值</param>
        public override void setString(String value)
        {
            m_value = value;
        }
    }

    /// <summary>
    /// 输入框单元格
    /// </summary>
    public class FCGridTextBoxCell : FCGridViewCell
    {
        /// <summary>
        /// 创建输入框单元格
        /// </summary>
        public FCGridTextBoxCell()
        {
            FCTextBox textBox = new FCTextBox();
            textBox.setBorderColor(FCColor.None);
            textBox.setDisplayOffset(false);
            setView(textBox);
        }

        /// <summary>
        /// 获取按钮视图
        /// </summary>
        public FCTextBox getTextBox()
        {
            if (getView() != null)
            {
                return getView() as FCTextBox;
            }
            else
            {
                return null;
            }
        }
    }

    /// <summary>
    /// 小数型单元格
    /// </summary>
    public class FCGridPercentCell : FCGridDoubleCell
    {
        /// <summary>
        /// 创建单元格
        /// </summary>
        public FCGridPercentCell()
        {
            m_digit = 2;
        }

        /// <summary>
        /// 创建单元格
        /// </summary>
        /// <param name="value">数值</param>
        public FCGridPercentCell(double value)
            : base(value)
        {
            m_digit = 2;
        }

        /// <summary>
        /// 获取要绘制的文本
        /// </summary>
        /// <returns></returns>
        public override String getPaintText()
        {
            double value = getDouble() * 100;
            String strValue = FCTran.getValueByDigit(value, m_digit);
            return strValue + "%";
        }
    }
}
